#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    : 2023/11/28 22:53
# @function: the script is used to do something.
# @version : 

import requests
from lxml import etree

"""
如果需要在Python中使用xpath语法
    需要安装包：lmxl
"""
# etree.HTML 将字符串转换成 element元素对象 element具有xpath方法 能接受字符串和字节数据
# html = etree.HTML(text)

# 获取资源地址
url = 'https://www.77xsw.cc/fenlei/1_1/'

response = requests.get(url)
response.encoding = 'gbk'

# 将字符串转换成元素对象
html = etree.HTML(response.text)
# xpath 获取的数据是列表信息
html1 = html.xpath('//div[@id="mm_14"]/ul/li[position() >1]')[1]
print(type(html))
# 将元素对象，在转换成字符串对象
data = etree.tostring(html1, encoding='utf-8', method='html').decode()
print(data)
